package com.ophiux.FeverManagement.aplication.serviceImpl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.ophiux.FeverManagement.aplication.bean.delPatientTreatmentRequest;
import com.ophiux.FeverManagement.aplication.bean.delPatientTreatmentResponse;
import com.ophiux.FeverManagement.aplication.service.IDelPatientTreatmentAppPort;
import com.ophiux.FeverManagement.domain.repository.IPatientTreatmentRepository;
import com.ophiux.micro.core.application.Result;
import com.ophiux.micro.core.application.ResultEnum;

import lombok.extern.slf4j.Slf4j;

@Service
@Slf4j
public class DelPatientTreatmentAppService implements IDelPatientTreatmentAppPort{
	@Autowired
	IPatientTreatmentRepository patientTreatmentRepository;
	
	@Override
	public Result<delPatientTreatmentResponse> execute(delPatientTreatmentRequest request) {
		delPatientTreatmentResponse resp = new delPatientTreatmentResponse();
		try {
			if (!request.isParamValid()) {
				return Result.fail(ResultEnum.requestParamFail);
			}
			
			patientTreatmentRepository.delete(request.getPATIENT_TREATMENT_ID());
			resp.setRESULT("1");
		} catch (Exception e) {
			log.info("DelPatientTreatmentAppService=》execute(),程序异常：", e);
			e.printStackTrace();
			return Result.fail(ResultEnum.requestException);
		}
		return Result.success(resp);
	}

}
